package com.wang.ymcc.web.controller;


import com.wang.lwm.result.JSONResult;
import com.wang.lwm.result.PageList;
import com.wang.ymcc.CourseDoc;
import com.wang.ymcc.domain.Course;
import com.wang.ymcc.dto.SearchParamDto;
import com.wang.ymcc.service.ICourseDocService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private ICourseDocService courseDocService;
    @PostMapping("/save")
    public JSONResult save(@RequestBody CourseDoc doc){
        courseDocService.save(doc);
        return JSONResult.success();
    }
    @PostMapping(value = "/delete")
    public JSONResult delete(@RequestBody Course course){
        courseDocService.delete(course.getId());
        return JSONResult.success();
    }

    @PostMapping("/course")
    public JSONResult courseSearch(@RequestBody SearchParamDto dto){
        PageList<CourseDoc> pageList = courseDocService.searchCourse(dto);
        return JSONResult.success(pageList);
    }
}
